package main

import (
	"QingDai-Gin/controller/AddressController"
	"QingDai-Gin/controller/CommodityController"
	"QingDai-Gin/controller/CouponController"
	"QingDai-Gin/controller/EvaluateController"
	"QingDai-Gin/controller/OrderController"
	"QingDai-Gin/controller/ShopController"
	"QingDai-Gin/controller/UserController"
	_ "QingDai-Gin/docs"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	gs "github.com/swaggo/gin-swagger"
)

func init() {

}

//swag init --generalInfo cmd/main/main.go

// @title 青黛后端
// @version 1.0
// @description 青黛商城
// @contact.name LiuZiMing
// @contact.url https://gitee.com/liuziming33
// @contact.email 3335308825@qq.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host 127.0.0.1:7000
func main() {
	router := gin.Default()

	router.GET("/swagger/*any", gs.WrapHandler(swaggerFiles.Handler))

	addressRouter := router.Group("/address")
	{
		// /address
		addressRouter.GET("/all", AddressController.GetAllAddress)
	}
	addressJwtRouter := addressRouter.Group("/jwt")
	{
		// /address/jwt
		addressJwtRouter.GET("/", AddressController.GetAddressByJwt)
		addressJwtRouter.POST("/", AddressController.CreateAddressByJwt)
		addressJwtRouter.GET("/id", AddressController.GetAddressByIdAndJwt)
		addressJwtRouter.PUT("/id", AddressController.UpdateAddressByIdAndJwt)
		addressJwtRouter.DELETE("/id", AddressController.DeleteAddressByIdAndJwt)

	}
	//-----------------------------------------------------------------------------------------------
	commodityRouter := router.Group("/commodity")
	{
		// /commodity
		commodityRouter.GET("/all", CommodityController.GetAllCommodities)
		commodityRouter.GET("/shopId", CommodityController.GetCommoditiesByShopId)
		commodityRouter.GET("/id", CommodityController.GetCommoditiesById)
	}
	commodityJwtRouter := commodityRouter.Group("/jwt")
	{
		// /commodity/jwt
		commodityJwtRouter.POST("/shopId", CommodityController.CreateCommoditiesByShopIdAndJwt)
		commodityRouter.GET("/orderId", CommodityController.GetCommoditiesByOrderIdAndJwt)
	}
	commodityJwtIdRouter := commodityJwtRouter.Group("/id")
	{
		// /commodity/jwt/id
		commodityJwtIdRouter.PUT("/", CommodityController.UpdateCommoditiesByIdAndJwt)
		commodityJwtIdRouter.DELETE("/", CommodityController.DeleteCommoditiesByIdAndJwt)
		commodityJwtIdRouter.GET("/enable", CommodityController.ChangeCommodityEnableByIdAndJwt)
	}
	//-----------------------------------------------------------------------------------------------
	couponRouter := router.Group("/coupon")
	{
		couponRouter.GET("/shopId", CouponController.GetCouponByShopId)
	}
	couponJwtRouter := couponRouter.Group("jwt")
	{
		// /coupon/jwt
		couponJwtRouter.GET("/", CouponController.GetCouponByJwt)
		couponJwtRouter.POST("/shopId", CouponController.CreateCouponByShopIdAndJwt)
		couponJwtRouter.PUT("/id", CouponController.UpdateCouponByIdAndJwt)
		couponJwtRouter.GET("/id", CouponController.GetCouponByIdAndJwt)
		couponJwtRouter.DELETE("/id", CouponController.DeleteCouponByIdAndJwt)
	}
	//-----------------------------------------------------------------------------------------------
	orderRouter := router.Group("/order")
	{
		// /order
		orderRouter.GET("/pay/id", OrderController.ChangePayTimeByIdAndJwt)
		orderRouter.GET("/send/id", OrderController.DeliverOrderByIdAndJwt)
	}
	orderJwtController := orderRouter.Group("/jwt")
	{
		// /order/jwt
		orderJwtController.GET("/", OrderController.GetOrderByJwt)
		orderJwtController.POST("/", OrderController.CreateOrderByJwt)
		orderJwtController.PUT("/id", OrderController.UpdateOrderByIdAndJwt)
		orderJwtController.GET("/id", OrderController.GetOrderByIdAndJwt)
		orderJwtController.DELETE("/id", OrderController.DeleteOrderByIdAndJwt)
		orderJwtController.GET("/shopId", OrderController.GetOrderByShopIdAndJwt)
	}
	//-----------------------------------------------------------------------------------------------
	shopRouter := router.Group("/shop")
	{ // /shop
		shopRouter.GET("/", ShopController.GetAllShop)
		shopRouter.GET("/id", ShopController.GetShopById)

	}
	shopJwtRouter := shopRouter.Group("/jwt")
	{ // /shop/jwt
		shopJwtRouter.GET("/", ShopController.GetShopByJwt)
		shopJwtRouter.POST("/", ShopController.CreateShopByJwt)
		shopJwtRouter.PUT("/id", ShopController.UpdateShopByIdAndJwt)
		shopJwtRouter.DELETE("/id", ShopController.DeleteShopByIdAndJwt)
	}
	//-----------------------------------------------------------------------------------------------
	userRouter := router.Group("/user")
	{
		// /user
		userRouter.GET("/textMessage", UserController.SendTextMessage)
		userRouter.POST("/", UserController.CreateUser)
	}
	userJwtRouter := userRouter.Group("/jwt")
	{
		// /user/jwt
		userJwtRouter.PUT("/", UserController.UpdateUserByJwt)
		userJwtRouter.GET("/", UserController.GetUserByJwt)
		userJwtRouter.DELETE("/", UserController.DeleteUserByJwt)
	}
	//-----------------------------------------------------------------------------------------------
	evaluateRouter := router.Group("/evaluate")
	{ // /evaluate
		evaluateRouter.GET("/", EvaluateController.GetEvaluateById)
		evaluateRouter.GET("/shopId", EvaluateController.GetEvaluateByShopId)
	}
	evaluateJwtRouter := evaluateRouter.Group("/jwt")
	{ // /evaluate/jwt
		evaluateJwtRouter.GET("/", EvaluateController.GetEvaluateByJwt)
		evaluateJwtRouter.POST("/", EvaluateController.CreateEvaluateByJwt)
		evaluateJwtRouter.GET("/orderId", EvaluateController.GetEvaluateByOrderIdAndJwt)
		evaluateJwtRouter.PUT("/id", EvaluateController.UpdateEvaluateByIdAndJwt)
		evaluateJwtRouter.PUT("/id", EvaluateController.UpdateEvaluateByIdAndJwt)
		evaluateJwtRouter.DELETE("/id", EvaluateController.DeleteEvaluateByIdAndJwt)
	}

	router.Run(":7000")
}
